/*
 * xpdiv.h
 *
 *  Created on: 2010-06-07
 *      Author: lxb
 */

#ifndef _XPDIV_H_INCLUDED_
#define _XPDIV_H_INCLUDED_

#ifdef __cplusplus
extern "C" {
#endif

/******************************************************************************
 * <Includes>
 *****************************************************************************/

/******************************************************************************
 * <Defines>
 *****************************************************************************/

/******************************************************************************
 * <Enums>
 *****************************************************************************/
/******************************************************************************
 * <Typedefs>
 *****************************************************************************/
typedef struct xpdiv_point xpdiv_point;
struct xpdiv_point
{
    xpuint x;
    xpuint y;
    xpbool isAvail;
    xpdiv_point *xnext;
    xpdiv_point *ynext;
};

typedef struct xpdiv_rect xpdiv_rect;
struct xpdiv_rect
{
    xpuint x;
    xpuint y;
    xpuint w;
    xpuint h;
};

typedef struct xpdiv xpdiv;
struct xpdiv
{
    xpuint x;
    xpuint y;
    xpuint w;
    xpuint h;
    xpdiv_point *root;
};
/******************************************************************************
 * <API declarations>
 *****************************************************************************/

xpdiv* xpdiv_create();
xpdiv* xpdiv_createx(xpuint x, xpuint y, xpuint w, xpuint h);
void xpdiv_delete(xpdiv *div);
xpint xpdiv_rect_get(xpdiv *div, xpdiv_rect *rect);
void xpdiv_point_insert(xpdiv *div, xpuint x, xpuint y);
void xpdiv_rect_insert(xpdiv *div, xpdiv_rect *rect);
void xpdiv_rect_occupy(xpdiv *div, xpdiv_rect *rect);
void xpdiv_rect_used(xpdiv *div, xpdiv_rect *rect);
void xpdiv_rect_newline(xpdiv *div, xpdiv_rect *rect);
void xpdiv_rect_x(xpdiv *div, xpuint x, xpdiv_rect *rect);

xpdiv_rect* xpdiv_rect_create();
void xpdiv_rect_delete(xpdiv_rect *r);

xpdiv_point* xpdiv_point_create();
void xpdiv_point_delete(xpdiv_point *point);
xpdiv_point* xpdiv_point_duplicate(xpdiv_point *point);

#ifdef __cplusplus
}
#endif

#endif /* _XPDIV_H_INCLUDED_ */


